﻿#pragma once

#include "../Enums.h"
#include "ItemData.h"
#include "SharedData.h"
#include "Stat.h"
#include <string>
#include <vector>

class ClientMagic
{
public:
    std::string Name;
    Spell Spell = static_cast<Spell>(0);
    unsigned char BaseCost = 0, LevelCost = 0, Icon = 0;
    unsigned char Level1 = 0, Level2 = 0, Level3 = 0;
    unsigned short Need1 = 0, Need2 = 0, Need3 = 0;

    unsigned char Level = 0, Key = 0, Range = 0;
    unsigned short Experience = 0;

    bool IsTempSpell = false;
    long long CastTime = 0, Delay = 0;

    ClientMagic();

    ClientMagic(BinaryReader *reader);

    void Save(BinaryWriter *writer);

};

class ClientRecipeInfo
{
public:
    unsigned int Gold = 0;
    unsigned char Chance = 0;
    UserItem *Item;
    std::vector<UserItem*> Tools = std::vector<UserItem*>();
    std::vector<UserItem*> Ingredients = std::vector<UserItem*>();

    virtual ~ClientRecipeInfo()
    {
        delete Item;
    }

    ClientRecipeInfo();


    ClientRecipeInfo(BinaryReader *reader);

    void Save(BinaryWriter *writer);
};

class ClientFriend
{
public:
    int Index = 0;
    std::string Name;
    std::string Memo = "";
    bool Blocked = false;

    bool Online = false;

    ClientFriend();

    ClientFriend(BinaryReader *reader);

    void Save(BinaryWriter *writer);
};

class ClientMail
{
public:
    unsigned long long MailID = 0;
    std::string SenderName;
    std::string Message;
    bool Opened = false, Locked = false, CanReply = false, Collected = false;

    DateTime DateSent;

    unsigned int Gold = 0;
    std::vector<UserItem*> Items = std::vector<UserItem*>();

    ClientMail();

    ClientMail(BinaryReader *reader);

    void Save(BinaryWriter *writer);
};

class ClientAuction
{
public:
    unsigned long long AuctionID = 0;
    UserItem *Item;
    std::string Seller = std::string::Empty;
    unsigned int Price = 0;
    DateTime ConsignmentDate = DateTime::MinValue;
    MarketItemType ItemType = static_cast<MarketItemType>(0);

    virtual ~ClientAuction()
    {
        delete Item;
    }

    ClientAuction();

    ClientAuction(BinaryReader *reader);
    void Save(BinaryWriter *writer);
};

class ClientQuestInfo
{
public:
    int Index = 0;

    unsigned int NPCIndex = 0;

    std::string Name, Group;
    std::vector<std::string> Description = std::vector<std::string>();
    std::vector<std::string> TaskDescription = std::vector<std::string>();
    std::vector<std::string> CompletionDescription = std::vector<std::string>();

    int MinLevelNeeded = 0, MaxLevelNeeded = 0;
    int QuestNeeded = 0;
    RequiredClass ClassNeeded = static_cast<RequiredClass>(0);

    QuestType Type = static_cast<QuestType>(0);

    unsigned int RewardGold = 0;
    unsigned int RewardExp = 0;
    unsigned int RewardCredit = 0;
    std::vector<QuestItemReward*> RewardsFixedItem = std::vector<QuestItemReward*>();
    std::vector<QuestItemReward*> RewardsSelectItem = std::vector<QuestItemReward*>();

    unsigned int FinishNPCIndex = 0;

    bool getSameFinishNPC() const;

    ClientQuestInfo();

    ClientQuestInfo(BinaryReader *reader);
    void Save(BinaryWriter *writer);

    QuestIcon GetQuestIcon(bool taken = false, bool completed = false);
};

class ClientQuestProgress
{
public:
    int Id = 0;

    ClientQuestInfo *QuestInfo;

    std::vector<std::string> TaskList = std::vector<std::string>();

    bool Taken = false;
    bool Completed = false;
    bool New = false;

    virtual ~ClientQuestProgress()
    {
        delete QuestInfo;
    }

    QuestIcon getIcon() const;

    ClientQuestProgress();

    ClientQuestProgress(BinaryReader *reader);

    void Save(BinaryWriter *writer);
};

class ClientBuff
{
public:
    BuffType Type = static_cast<BuffType>(0);
    std::string Caster;
    bool Visible = false;
    unsigned int ObjectID = 0;
    long long ExpireTime = 0;
    bool Infinite = false;
    Stats *Stats;

    std::vector<int> Values;

    virtual ~ClientBuff()
    {
        delete Stats;
    }

    ClientBuff();

    ClientBuff(BinaryReader *reader);

    void Save(BinaryWriter *writer);
};
